<template>
	<view>
		<nav-bar></nav-bar>
		<view style="padding: 0 30px;">
			<view>
				<u-radio-group v-model="radiovalue" placement="row" @change="groupChange">
					<u-radio
						:customStyle="{ marginBottom: '8px' }"
						v-for="(item, index) in radiolist"
						:key="index"
						:label="item.name"
						:name="item.value"
						@change="radioChange"
					></u-radio>
				</u-radio-group>
			</view>
			<view v-if="radiovalue == 'find'">
				<view style="margin-top:18px;">
					<view style="font-size: 12px;font-weight: 400;color: #000000;">
						<text style="color:#ED1A23;">*</text>
						需求标题
					</view>
					<view><u--input placeholder="例：需要土地50亩建厂房生产" border="surround" v-model="temp.xuqiubiaoti"></u--input></view>
				</view>
				<view style="margin-top:18px;">
					<view style="font-size: 12px;font-weight: 400;color: #000000;">
						<text style="color:#ED1A23;">*</text>
						意向区域
					</view>
					<view><u--input placeholder="例：如北京·海淀" border="surround" v-model="temp.yixiangquyu"></u--input></view>
				</view>
				<view style="margin-top:18px;">
					<view style="font-size: 12px;font-weight: 400;color: #000000;">
						<text style="color:#ED1A23;">*</text>
						投资类型：
					</view>
					<view><u--input placeholder="购买自建房" border="surround" v-model="temp.touzileixing"></u--input></view>
				</view>
				<view style="margin-top:18px;">
					<view style="font-size: 12px;font-weight: 400;color: #000000;">
						<text style="color:#ED1A23;">*</text>
						需求介绍
					</view>
					<view style="margin-top:12px;"><u--input placeholder="请输入内容" border="surround" v-model="temp.xuqiujianshao"></u--input></view>
				</view>
				<view style="margin-top:18px;">
					<view style="font-size: 12px;font-weight: 400;color: #000000;">
						<text style="color:#ED1A23;">*</text>
						你的姓名
					</view>
					<view><u--input placeholder="请输入你的姓名" border="surround" v-model="temp.xingming"></u--input></view>
				</view>
				<view style="margin-top:18px;">
					<view style="font-size: 12px;font-weight: 400;color: #000000;">
						<text style="color:#ED1A23;">*</text>
						你的手机
					</view>
					<view><u--input placeholder="请输入手机号" border="surround" v-model="temp.lianxifangshi"></u--input></view>
				</view>
				<view style="margin-top:23px;"><u-button type="primary" color="#FE7743" text="提交" @click="send"></u-button></view>
			</view>
			<view v-if="radiovalue == 'have'">
				<view style="margin-top:18px;">
					<view style="font-size: 12px;font-weight: 400;color: #000000;">
						<text style="color:#ED1A23;">*</text>
						招商主题：
					</view>
					<view><u--input placeholder="例：有50亩土地可自建厂房" border="surround" v-model="temp.zhaoshangzhuti"></u--input></view>
				</view>
				<view style="margin-top:18px;">
					<view style="font-size: 12px;font-weight: 400;color: #000000;">
						<text style="color:#ED1A23;">*</text>
						载体区域：
					</view>
					<view><u--input placeholder="例：如北京·海淀" border="surround" v-model="temp.zaitiquyu"></u--input></view>
				</view>
				<view style="margin-top:18px;">
					<view style="font-size: 12px;font-weight: 400;color: #000000;">
						<text style="color:#ED1A23;">*</text>
						招商载体：
					</view>
					<view><u--input placeholder="土地" border="surround" v-model="temp.zhaoshangzaiti"></u--input></view>
				</view>
				<view style="margin-top:18px;">
					<view style="font-size: 12px;font-weight: 400;color: #000000;">
						<text style="color:#ED1A23;">*</text>
						载体面积：
					</view>
					<view><u--input placeholder="10000平方米" border="surround" v-model="temp.zaitimianji"></u--input></view>
				</view>
				<view style="margin-top:18px;">
					<view style="font-size: 12px;font-weight: 400;color: #000000;">
						<text style="color:#ED1A23;">*</text>
						转让方式：
					</view>
					<view><u--input placeholder="出售" border="surround" v-model="temp.zhuangrangfangshi"></u--input></view>
				</view>
				<view style="margin-top:18px;">
					<view style="font-size: 12px;font-weight: 400;color: #000000;">
						<text style="color:#ED1A23;">*</text>
						转让价格：
					</view>
					<view><u--input placeholder="500万/亩" border="surround" v-model="temp.zhuangrangjiage"></u--input></view>
				</view>
				<view style="margin-top:18px;">
					<view style="font-size: 12px;font-weight: 400;color: #000000;">
						<text style="color:#ED1A23;">*</text>
						需求介绍
					</view>
					<view style="margin-top:12px;"><u--input placeholder="请输入内容" border="surround" v-model="temp.xuqiujieshao"></u--input></view>
				</view>
				<view style="margin-top:18px;">
					<view style="font-size: 12px;font-weight: 400;color: #000000;">
						<text style="color:#ED1A23;">*</text>
						你的姓名
					</view>
					<view><u--input placeholder="请输入你的姓名" border="surround" v-model="temp.xingming"></u--input></view>
				</view>
				<view style="margin-top:18px;">
					<view style="font-size: 12px;font-weight: 400;color: #000000;">
						<text style="color:#ED1A23;">*</text>
						你的手机
					</view>
					<view><u--input placeholder="请输入手机号" border="surround" v-model="temp.lianxifangshi"></u--input></view>
				</view>
				<view style="margin-top:23px;"><u-button type="primary" color="#FE7743" text="提交" @click="send"></u-button></view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			temp: {
				xuqiubiaoti: '',
				yixiangquyu: '',
				touzileixing: '',
				xuqiujianshao: '',
				xuqiujieshao:'',
				zhaoshangzhuti: '',
				zaitiquyu: '',
				zhaoshangzaiti: '',
				zaitimianji: '',
				zhuangrangfangshi: '',
				zhuangrangjiage: '',
				zaititupianurl: '',
				xingming: '',
				lianxifangshi:''
			},
			radiolist: [
				{
					name: '我有项目',
					value: 'find',
					disabled: false
				},
				{
					name: '我有园区',
					value: 'have',
					disabled: false
				}
			],
			radiovalue: 'find'
		};
	},
	methods: {
		resetTemp() {
			this.temp = {
				xuqiubiaoti: '',
				yixiangquyu: '',
				touzileixing: '',
				xuqiujianshao: '',
				xuqiujieshao:'',
				zhaoshangzhuti: '',
				zaitiquyu: '',
				zhaoshangzaiti: '',
				zaitimianji: '',
				zhuangrangfangshi: '',
				zhuangrangjiage: '',
				zaititupianurl: '',
				xingming: '',
				lianxifangshi:''
			};
		},
		groupChange(n) {
			console.log('groupChange', n);
			// this.groupCha = n;
		},
		radioChange(n) {
			console.log('radioChange', n);
			this.radiovalue = n;
		},
		send() {
			let that = this;
			// console.log(that.groupCha);
			if (that.radiovalue == 'find') {
				if (this.temp.xuqiubiaoti == '') {
					return uni.showToast({
						title: '需求标题不能为空',
						icon: 'none',
						duration: 2000
					});
				}
				if (this.temp.yixiangquyu == '') {
					return uni.showToast({
						title: '意向区域不能为空',
						icon: 'none',
						duration: 2000
					});
				}
				if (this.temp.touzileixing == '') {
					return uni.showToast({
						title: '投资类型不能为空',
						icon: 'none',
						duration: 2000
					});
				}
				if (this.temp.xuqiujianshao == '') {
					return uni.showToast({
						title: '需求介绍不能为空',
						icon: 'none',
						duration: 2000
					});
				}
				if (this.temp.xingming == '') {
					return uni.showToast({
						title: '姓名不能为空',
						icon: 'none',
						duration: 2000
					});
				}
				if (this.temp.lianxifangshi == '') {
					return uni.showToast({
						title: '手机号不能为空',
						icon: 'none',
						duration: 2000
					});
				}
				console.log(111);
				this.$apiCall.request('post', '/woyouxiangmu/add', that.temp, {
					sucCb(data) {
						console.log(data);
						// console.info(data);
						if (data.code === 0) {
							uni.showToast({
								title: data.msg,
								icon: 'none',
								duration: 2000
							});
							setTimeout(() => {
								uni.navigateBack();
							}, 1000);
						} else {
							uni.showToast({
								title: data.msg,
								icon: 'none',
								duration: 2000
							});
						}
					}
				});
			} else {
				if (this.temp.zhaoshangzhuti == '') {
					return uni.showToast({
						title: '招商主体不能为空',
						icon: 'none',
						duration: 2000
					});
				}
				if (this.temp.zhaoshangzaiti == '') {
					return uni.showToast({
						title: '招商载体不能为空',
						icon: 'none',
						duration: 2000
					});
				}
				if (this.temp.zaitimianji == '') {
					return uni.showToast({
						title: '载体面积不能为空',
						icon: 'none',
						duration: 2000
					});
				}
				if (this.temp.zhuangrangfangshi == '') {
					return uni.showToast({
						title: '转让方式不能为空',
						icon: 'none',
						duration: 2000
					});
				}
				if (this.temp.zhuangrangjiage == '') {
					return uni.showToast({
						title: '转让价格不能为空',
						icon: 'none',
						duration: 2000
					});
				}
				if (this.temp.xuqiujieshao == '') {
					return uni.showToast({
						title: '需求介绍不能为空',
						icon: 'none',
						duration: 2000
					});
				}
				if (this.temp.xingming == '') {
					return uni.showToast({
						title: '姓名不能为空',
						icon: 'none',
						duration: 2000
					});
				}
				if (this.temp.lianxifangshi == '') {
					return uni.showToast({
						title: '手机号不能为空',
						icon: 'none',
						duration: 2000
					});
				}
				this.$apiCall.request('post', '/woyouyuanqu/add', that.temp, {
					sucCb(data) {
						console.log(data);
						console.info(data);
						if (data.code === 0) {
							uni.showToast({
								title: data.msg,
								icon: 'none',
								duration: 2000
							});
							setTimeout(() => {
								uni.navigateBack();
							}, 1000);
						} else {
							uni.showToast({
								title: data.msg,
								icon: 'none',
								duration: 2000
							});
						}
					}
				});
			}
		}
	}
};
</script>

<style lang="scss"></style>
